var a = require("../../../@babel/runtime/helpers/interopRequireDefault").default,
  t = require("../../../utils/http"),
  e = a(require("../../../utils/util")),
  n = new t.HTTP;
Page({
  data: {
    taga: [{
      id: 1,
      name: "1月"
    }, {
      id: 2,
      name: "2月"
    }, {
      id: 3,
      name: "3月"
    }, {
      id: 4,
      name: "4月"
    }, {
      id: 5,
      name: "5月"
    }, {
      id: 6,
      name: "6月"
    }, {
      id: 7,
      name: "7月"
    }, {
      id: 8,
      name: "8月"
    }, {
      id: 9,
      name: "9月"
    }, {
      id: 10,
      name: "10月"
    }, {
      id: 11,
      name: "11月"
    }, {
      id: 12,
      name: "12月"
    }],
    course: [{
      id: 1,
      name: "新增渠道统计"
    }, {
      id: 2,
      name: "人才/高企引进"
    }],
    currentItem: e.default.formatDates(new Date),
    courseItem: 1,
    year: e.default.formatYear(new Date),
    list: 2
  },
  onLoad: function () {
    var a = this;
    n.request({
      url: "https://www.qlsyyun.com:3000/tank/process",
      data: {
        arr: 1,
        yf: a.data.currentItem
      }
    }).then((function (t) {
      if (0 == t.data.length)
        a.setData({
          sum: 0,
          alone: []
        });
      else {
        for (var e = t.data.map((function (a) {
            return a.rcs
          })), n = 0, r = 0; r < e.length; r++)
          n += e[r];
        a.setData({
          alone: t.data,
          sum: n
        })
      }
    }))
  },
  tagChoose: function (a) {
    var t = this,
      e = a.currentTarget.dataset.id;
    t.setData({
        currentItem: e
      }),
      2 == t.data.list ? n.request({
        url: "https://www.qlsyyun.com:3000/tank/process",
        data: {
          arr: 1,
          yf: e
        }
      }).then((function (a) {
        for (var e = a.data.map((function (a) {
            return a.rcs
          })), n = 0, r = 0; r < e.length; r++)
          n += e[r];
        0 == a.data.length ? t.setData({
          alone: [],
          sum: n
        }) : t.setData({
          alone: a.data,
          sum: n
        })
      })) : 3 == t.data.list && (1 == e ? t.setData({
        years: t.data.year[0] - 2
      }) : 2 == e ? t.setData({
        years: t.data.year[0] - 1
      }) : t.setData({
        years: t.data.year[0]
      }), n.request({
        url: "https://www.qlsyyun.com:3000/tank/process",
        data: {
          arr: 2,
          year: t.data.years
        }
      }).then((function (a) {
        if (0 == a.data.length)
          t.setData({
            sum: 0,
            sums: 0,
            alone: []
          });
        else {
          for (var e = a.data, n = e.map((function (a) {
              return a.rcs
            })), r = 0, s = 0, u = 0; u < n.length; u++)
            r += n[u];
          for (var d = e.map((function (a) {
              return a.gqs
            })), i = 0; i < d.length; i++)
            s += d[i];
          t.setData({
            alone: a.data,
            sum: r,
            sums: s
          })
        }
      })))
  },
  tagClick: function (a) {
    var t = this,
      r = a.currentTarget.dataset.id;
    2 == r ? (t.setData({
      taga: [{
        id: 1,
        name: t.data.year[0] - 2
      }, {
        id: 2,
        name: t.data.year[0] - 1
      }, {
        id: 3,
        name: t.data.year[0]
      }],
      currentItem: 3,
      courseItem: r,
      list: 3
    }), n.request({
      url: "https://www.qlsyyun.com:3000/tank/process",
      data: {
        arr: 2,
        year: t.data.year[0]
      }
    }).then((function (a) {
      for (var e = a.data, n = e.map((function (a) {
          return a.rcs
        })), r = 0, s = 0, u = 0; u < n.length; u++)
        r += n[u];
      for (var d = e.map((function (a) {
          return a.gqs
        })), i = 0; i < d.length; i++)
        s += d[i];
      0 == a.data.length ? t.setData({
        sum: r,
        sums: s
      }) : t.setData({
        alone: a.data,
        sum: r,
        sums: s
      })
    }))) : (t.setData({
      taga: [{
        id: 1,
        name: "1月"
      }, {
        id: 2,
        name: "2月"
      }, {
        id: 3,
        name: "3月"
      }, {
        id: 4,
        name: "4月"
      }, {
        id: 5,
        name: "5月"
      }, {
        id: 6,
        name: "6月"
      }, {
        id: 7,
        name: "7月"
      }, {
        id: 8,
        name: "8月"
      }, {
        id: 9,
        name: "9月"
      }, {
        id: 10,
        name: "10月"
      }, {
        id: 11,
        name: "11月"
      }, {
        id: 12,
        name: "12月"
      }],
      courseItem: r,
      currentItem: e.default.formatDates(new Date),
      list: 2
    }), n.request({
      url: "https://www.qlsyyun.com:3000/tank/process",
      data: {
        arr: 1,
        yf: e.default.formatDates(new Date)
      }
    }).then((function (a) {
      var e = a.data;
      if (0 == a.data.length)
        t.setData({
          alone: [],
          sum: 0
        });
      else {
        for (var n = e.map((function (a) {
            return a.rcs
          })), r = 0, s = 0; s < n.length; s++)
          r += n[s];
        t.setData({
          alone: a.data,
          sum: r
        })
      }
    })))
  }
});